/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 19182
 * Date: 2025-10-26
 * Time: 11:07
 */
class Solution {
    public String convert(String s, int numRows) {
        String ret = "";
        if(numRows == 1){
            return s;
        }
        int len = s.length();
        char[][] arr = new char[numRows][len];
        int j = 0;
        int i = 0;
        int k = 0;
        while(k < len){
            while(k < len && i < numRows){
                char ch = s.charAt(k);
                arr[i][j] = ch;
                i++;
                k++;
            }
            int l = i - 1;
            //到这里i等于n - 1;
            while(k < len && l != 0){
                i--;
                j++;
                char ch = s.charAt(k);
                arr[i][j] = ch;
                k++;
            }
            i = l + 1;
        }
        for(int r = 0; r < arr.length; r++){
            for(int l = 0; l < arr[0].length; l++){
                if(arr[r][l] != '\u0000'){
                    ret += arr[r][l];
                }
            }
        }
        return ret;
    }

    public static void main(String[] args) {


    }
}
public class Test {
}
